Attribute VB_Name = "FileDialog"
Option Explicit

Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
    Alias "GetOpenFileNameA" ( _
    pOpenfilename As OPENFILENAME) As Long

Private Type OPENFILENAME
    lStructSize       As Long
    hwndOwner         As Long
    hInstance         As Long
    lpstrFilter       As String
    lpstrCustomFilter As String
    nMaxCustFilter    As Long
    nFilterIndex      As Long
    lpstrFile         As String
    nMaxFile          As Long
    lpstrFileTitle    As String
    nMaxFileTitle     As Long
    lpstrInitialDir   As String
    lpstrTitle        As String
    flags             As Long
    nFileOffset       As Integer
    nFileExtension    As Integer
    lpstrDefExt       As String
    lCustData         As Long
    lpfnHook          As Long
    lpTemplateName    As String
End Type

Function Open_Comdlg32() As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim strFilter As String

OpenFile.lStructSize = Len(OpenFile)
'// Define your wildcard string here
'// Note we pad the strings with Chr(0)
'// This indicates an end of a string
strFilter = "My Files (*.ini)" & Chr(0) & "*.ini" & Chr(0)

With OpenFile
    .lpstrFilter = strFilter
    .nFilterIndex = 1
    .lpstrFile = String(257, 0)
    .nMaxFile = Len(.lpstrFile) - 1
    .lpstrFileTitle = .lpstrFile
    .nMaxFileTitle = .nMaxFile
    .lpstrInitialDir = "d:\ATE\Config"
    .lpstrTitle = "Please Select the Proper Config Files"
    .flags = 0
End With

lReturn = GetOpenFileName(OpenFile)
    If lReturn = 0 Then
        MsgBox "User cancelled", vbOKOnly + vbQuestion, "Warning!"
    Else
        'MsgBox "User selected" & ":=" & OpenFile.lpstrFile
        Open_Comdlg32 = OpenFile.lpstrFile
    End If

End Function

